
package com.roc.web.action.setting;

import java.sql.Date;
import java.util.ArrayList;
import java.util.List;

import com.roc.page.BaseSearchCondition;
import com.roc.page.WhereHQLFieldBean;
import com.roc.util.Constance;

/**
 * @author Feng haitao
 *
 */
public class CalcuSearchCondition extends BaseSearchCondition {

	private String merNo;
	private String etstermId;
	private String realName;
	private String settFlag;
	private String minDate;
	private String maxDate;
	private String orgCode;
	private String etstrace;
	private String batchno;
	private String termtrace;
	private String period;
	private String account;
	private String sysTermTrace;

	/* (non-Javadoc)
	 * @see com.roc.page.BaseSearchCondition#getOrderPartOfHQL()
	 */
	@Override
	protected String getOrderPartOfHQL() {
		// TODO Auto-generated method stub

		return " order by t.etsdate,t.etstime ";
	}

	/* (non-Javadoc)
	 * @see com.roc.page.BaseSearchCondition#getRowCountHQL()
	 */
	@Override
	protected String getRowCountHQL() {
		StringBuffer sb = new StringBuffer();
		sb
				.append("select count(*) from t_transjnls_calcu t,ESMIDINFO e where 1=1 and t.merno=e.mid");
		
		return sb.toString();
	}

	/* (non-Javadoc)
	 * @see com.roc.page.BaseSearchCondition#getSearchHQL()
	 */
	@Override
	protected String getSearchHQL() {
		// TODO Auto-generated method stub

		return " select t.merno,e.MER_NAME,t.etstermId,t.account,t.respcode,t.TERMTRACE,t.ETSTRACE,t.etstime,t.etsdate,t.AMOUNT,t.MERFEE,t.SETT_FLAG,t.calcuamount,t.settbatch,t.calcudate,t.period from t_transjnls_calcu t,ESMIDINFO e where 1=1 and t.merno=e.mid ";
	}

	/* (non-Javadoc)
	 * @see com.roc.page.BaseSearchCondition#getWhereHQLFieldBeanList()
	 */
	@Override
	protected List<WhereHQLFieldBean> getWhereHQLFieldBeanList() {
		List<WhereHQLFieldBean> filedBeanList = new ArrayList<WhereHQLFieldBean>();

		if (Constance.isNotEmpty(merNo)) {
			filedBeanList.add(new WhereHQLFieldBean("t.merNo", merNo.trim()
					.trim(), "=", false));
		}
		if (Constance.isNotEmpty(account)) {
			filedBeanList.add(new WhereHQLFieldBean("t.account", account.trim()
					.trim(), "=", false));
		}
		if (Constance.isNotEmpty(etstrace)) {
			filedBeanList.add(new WhereHQLFieldBean("t.ETSTRACE", etstrace
					.trim().trim(), "=", false));
		}
		if (Constance.isNotEmpty(etstermId)) {
			filedBeanList.add(new WhereHQLFieldBean("t.etstermId", etstermId
					.trim().trim(), "=", false));
		}
		if (Constance.isNotEmpty(settFlag)) {
			filedBeanList.add(new WhereHQLFieldBean("t.sett_Flag", settFlag
					.trim().trim(), "=", false));
		}

		if (Constance.isNotEmpty(realName)) {
			filedBeanList.add(new WhereHQLFieldBean("e.MER_NAME", realName
					.trim(), "LIKE", false, "ALL"));
		}
		if (Constance.isNotEmpty(sysTermTrace)) {
			filedBeanList.add(new WhereHQLFieldBean("t.ETSTRACE", sysTermTrace
					.trim(), "LIKE", false, "END"));
		}
		if (Constance.isNotEmpty(orgCode)) {
			filedBeanList.add(new WhereHQLFieldBean("e.BELONG_BRANCH", orgCode
					.trim().trim(), "=", false));
		}
		if (Constance.isNotEmpty(batchno)) {
			filedBeanList.add(new WhereHQLFieldBean("t.settbatch", batchno
					.trim().trim(), "=", false));
		}
		if (Constance.isNotEmpty(termtrace)) {
			filedBeanList.add(new WhereHQLFieldBean("t.termtrace", termtrace
					.trim().trim(), "=", false));
		}
		if (Constance.isNotEmpty(period)) {
			filedBeanList.add(new WhereHQLFieldBean("t.period", period
					.trim().trim(), "=", false));
		}

		if (Constance.isNotEmpty(minDate) && Constance.isNotEmpty(maxDate)) {
			//Date startDate = Constance.formateDate(minDate);
			//Date endDate = Constance.formateDate(maxDate);
			String startDate = minDate.replace("-", "");
			String endDate = maxDate.replace("-", "");
			filedBeanList.add(new WhereHQLFieldBean("t.ETSDATE", startDate,
					">=", false));
			filedBeanList.add(new WhereHQLFieldBean("t.ETSDATE", endDate,
					"<=", false));
		}

		return filedBeanList;
	}

	public String getBatchno() {
		return batchno;
	}

	public void setBatchno(String batchno) {
		this.batchno = batchno;
	}

	public String getEtstrace() {
		return etstrace;
	}

	public void setEtstrace(String etstrace) {
		this.etstrace = etstrace;
	}

	public String getOrgCode() {
		return orgCode;
	}

	public void setOrgCode(String orgCode) {
		this.orgCode = orgCode;
	}

	/**
	 * @return the realName
	 */
	public String getRealName() {
		return realName;
	}

	/**
	 * @param realName the realName to set
	 */
	public void setRealName(String realName) {
		this.realName = realName;
	}

	/**
	 * @return the minDate
	 */
	public String getMinDate() {
		return minDate;
	}

	/**
	 * @param minDate the minDate to set
	 */
	public void setMinDate(String minDate) {
		this.minDate = minDate;
	}

	/**
	 * @return the maxDate
	 */
	public String getMaxDate() {
		return maxDate;
	}

	/**
	 * @param maxDate the maxDate to set
	 */
	public void setMaxDate(String maxDate) {
		this.maxDate = maxDate;
	}

	public String getMerNo() {
		return merNo;
	}

	public void setMerNo(String merNo) {
		this.merNo = merNo;
	}

	public String getEtstermId() {
		return etstermId;
	}

	public void setEtstermId(String etstermId) {
		this.etstermId = etstermId;
	}

	public String getSettFlag() {
		return settFlag;
	}

	public void setSettFlag(String settFlag) {
		this.settFlag = settFlag;
	}
	
	public String getTermtrace() {
		return termtrace;
	}

	public void setTermtrace(String termtrace) {
		this.termtrace = termtrace;
	}

	public String getPeriod() {
		return period;
	}

	public void setPeriod(String period) {
		this.period = period;
	}

	public String getAccount() {
		return account;
	}

	public void setAccount(String account) {
		this.account = account;
	}

	

	public String getSysTermTrace() {
		return sysTermTrace;
	}

	public void setSysTermTrace(String sysTermTrace) {
		this.sysTermTrace = sysTermTrace;
	}

	public static void main(String[] args) {
		CalcuSearchCondition s = new CalcuSearchCondition();
		Object[] ids = new Object[] { "dxpeng", "lisi", "wangwu" };
		//s.setSuperiorId(1l);

		try {

			System.out.println(s.getFullSearchHQL(null));
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
